<template>
  <view>

    
    <uni-swipe-action>
      <view v-for="(goods,i) in collection" :key="i"  @click="gotoDetail(goods)">
      <!-- 右滑删除实现 -->
      <uni-swipe-action-item :right-options="options" @click="swiperItemClickHandler(goods.goods_id)">
        <my-goods :goods="goods"></my-goods>
      </uni-swipe-action-item>
      </view>
    </uni-swipe-action>
      
    
    
  </view>
</template>

<script>
  import {mapState,mapMutations} from 'vuex'

  
  export default {
    data() {
      return {
        // 右滑删除的内容
        options:[{
          text:'删除',
          style:{
            backgroundColor:'#C00000'
          }
        }],
        

      };
    },
    
    computed:{
      ...mapState('m_collection',['collection']),

    },
    
    
    methods:{
      ...mapMutations('m_collection',['removeGoodsById']),
      
      gotoDetail(goods){
        // console.log(1)
        
        uni.navigateTo({
          url:'/subpkg/goods_detail/goods_detail?goods_id=' + goods.goods_id
        })
      },
      

      
      // 右滑删除
      swiperItemClickHandler(goods_id){
        this.removeGoodsById(goods_id)
      }

    },
    
    onReachBottom(){
      if(this.queryObj.pagenum * this.queryObj.pagesize >= this.total) return uni.$showMsg('数据加载完毕！')
    }
  }
</script>

<style lang="scss">

</style>
